<template>
  <div>
    <!--条件查询开始-->
    <inquiry-form @inquiryDta="inquirtDataFun"/>
    <!--条件查询结束-->

    <!--查询状态开始-->
    <inquiry-result :NoData="NoData" v-if="isResult"/>
    <!--查询状态结束-->

    <!--查询条件结果开始-->
    <iuqiry-card :selfInfoData="selfInfoData"/>
    <!--查询条件结果结束-->

    <!--load过渡组件开始-->
    <iuqiry-load :isLoadShow="isLoadShow" :contFont="contFont"/>
  </div>
</template>

<script>
import inquiryForm from './inquiry-form/inquiry-form'
import inquiryResult from 'components/inquiry-result/inquiry-result'
import iuqiryCard from 'components/inquiry-card/inquiry-card'
import iuqiryLoad from 'components/inquiry-laod/inquiry-laod'
import {mapActions, mapState} from 'vuex'
export default {
  components: {
    inquiryForm,
    inquiryResult,
    iuqiryCard,
    iuqiryLoad
  },
  data () {
    return {
      isResult: true,
      selfInfoData: [],
      isLoadShow: false,
      contFont: '',
      NoData: '暂无记录'
    }
  },
  computed: {
    ...mapState('searchData/', ['searchData'])
  },
  methods: {
    ...mapActions('searchData/', ['setSearchDataInfo']),
    inquirtDataFun (data) {
      console.log(data)
      this.isLoadShow = true
      this.contFont = '正在查询中，请稍后...'
      const form = {
        url: '/api/3upsi_delay/dp/custApply/getApplyOrderByParam',
        userMsg: data
      }
      this._axios.postAxiosData(form)
        .then(res => {
          this.isLoadShow = false
          if (res.data.state === false) {
            this.NoData = res.data.msg
          } else {
            if (res.data.length === 0) {
              this.isResult = true
            }
            if (res.data.length > 0) {
              this.isResult = false
              this.setSearchDataInfo(res.data)
              this.selfInfoData = res.data
            }
          }
        })
        .catch(err => {
          this.isLoadShow = false
          this.isResult = true
          this.NoData = '网络链接超时，请稍后再试'
          console.log(err.data)
        })
    },
    initSearchData () {
      if (this.searchData !== null) {
        this.selfInfoData = this.searchData
        this.isResult = false
      } else {
        this.isResult = true
      }
    }
  },
  created () {
    document.title = '其他旅客查询'
  },
  mounted () {
    this.initSearchData()
  }
}
</script>

<style lang="scss" scoped>
</style>
